<div class="loader"></div>
<div class="row filter-form-container">
{{ Form::open(array('url' => $base, 'id' => 'form-filter')) }}
	<div class="form-group col-md-5">
		@if ( !empty($vendors) )
			{{ Form::label('filter_vendor', $text_filter_vendor) }}
			{{ Form::select('filter_vendor', $vendors, Input::get('filter_vendor'), array('class' => 'form-control')) }}
		@endif
		
		@if ( !empty($companies) )
			{{ Form::label('filter_company', $text_filter_company) }}
			{{ Form::select('filter_company', $companies, Input::get('filter_company'), array('class' => 'form-control')) }}
		@endif
		
		@if ( !empty($branches) )
			{{ Form::label('filter_branch[]', $text_filter_branch) }}
			{{ Form::select('filter_branch[]', $branches, $filters['selected_branch'], array('class' => 'form-control', 'multiple' => true )) }}
		@endif

		@if ( !empty($sizes) )
			{{ Form::label('filter_size', $text_filter_size) }}
			{{ Form::select('filter_size', $sizes, Input::get('filter_size'), array('class' => 'form-control')) }}
		@endif
		
		{{ Form::label('filter_voucher', $text_filter_voucher) }}
		{{ Form::select('filter_voucher', array('No', 'Yes'), Input::get('filter_voucher'), array('class' => 'form-control')) }}
	</div>

	<div class="form-group col-md-7">
		{{ Form::label('filter_ids', $text_filter_ids) }}<br/>
		{{ Form::textarea('filter_ids', Input::get('filter_ids'), ['size' => '45x3', 'placeholder' => $text_filter_line_separated ]) }}
		<br/>
		
		{{ Form::label('filter_order_ids', $text_filter_order_ids) }}<br/>
		{{ Form::textarea('filter_order_ids', Input::get('filter_order_ids'), ['size' => '45x3', 'placeholder' => $text_filter_line_separated ]) }}
		<br/>
			
		<strong>{{ $text_filter_order_date }}</strong>
		
		<div class="row">
			<div class='col-md-6'>
				<div class="form-group">
					{{ Form::text('filter_order_date_from', Input::get('filter_order_date_from'), array('class' => 'form-control', 'placeholder' => $text_filter_order_date_from )) }}
				</div>
			</div>
			<div class='col-md-6'>
				<div class="form-group">
					{{ Form::text('filter_order_date_to', Input::get('filter_order_date_to'), array('class' => 'form-control', 'placeholder' => $text_filter_order_date_to)) }}
				</div>
			</div>
		</div>
	</div>

	<div class="clearfix"></div>
	{{ HTML::link(URL::to($base), $text_filter, array('class' => 'btn btn-default', 'id'=> 'filter')) }}
{{ Form::close() }}
</div>
</br>
<p>&nbsp;</p>
@if ( $results->getTotal() )
</br>
<table id="tbl-processing" class="table table-bordered table-striped table-hover">
  <thead>
	<tr>
	<td style="width: 1px;" class="text-center"><input type="checkbox" class="main-po-item" /></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_id }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_ORDER_id }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_PRODUCT_id }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_prod_code }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_size_code }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_voucher }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_vendor_name }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_srp }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_quantity }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_peso }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_date_ordered }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_employee_name }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_company_name }}</a></td>
	  <td class="text-left"><a href="#" class="asc">{{ $list_company_branch_name }}</a></td>
	  <!-- <td class="text-right">{{ $list_action }}</td> -->
	</tr>
  </thead>
  <tbody>
	@foreach( $results as $key => $value )
	<tr>
		<td class="text-center">
			<input class="po-item" type="checkbox" name="selected[]" value="{{ $value->id }}" data-id="{{ $value->id }}"
			data-size_id="{{ $value->size_id }}" data-size_code="{{ $value->size_code}}" data-company="{{ $value->company_code }}" data-branch="{{ $value->branch_code }}" 
			data-prod_id="{{ $value->PRODUCT_id }}" data-prod_name="{{ $value->prod_name }}" data-prod_model="{{ $value->prod_code }}"
			data-prod_qty="{{ $value->quantity }}" data-prod_srp="{{ $value->prod_srp }}"/>
		</td>
		<td>{{ $value->id }}</td>
		<td>{{ $value->ORDER_id }}</td>
		<td>{{ $value->PRODUCT_id }}</td>
		<td>{{ $value->prod_code }}</td>
		<td>{{ $value->size_code }}</td>
		<td>@if ($value->voucher) {{ $text_yes }} @else  {{ $text_no }} @endif</td>
		<td>{{ ucwords($value->vendor_name) }}</td>
		<td>{{ number_format($value->srp, 2) }}</td>
		<td>{{ $value->quantity }}</td>
		<td>{{ number_format($value->peso, 2) }}</td>
		<td>{{ date_format(date_create($value->date_ordered), 'Y-m-d') }}</td>
		<td>{{ ucwords($value->firstname) }} {{ ucwords($value->lastname) }}</td>
		<td>{{ strtoupper($value->company_code) }}</td>
		<td>{{ ucwords($value->branch_name) }}</td>
		<!--<td>
			@if ( $value->voucher ) <a href="#">View Voucher</a> <a href="#">Send Voucher</a>@endif
			<a class="btn btn-info edit" href="{{ URL::to($base, array($value->id, 'edit')) }}" title="{{ $text_edit }}"><i class="fa fa-pencil"></i></a>
		</td>-->
	</tr>
	@endforeach
  </tbody>
</table>

<div class="box-footer">
	<div class="col-xs-14 text-center">
		<div class="dataTables_info">Showing {{ $results->getFrom() }} to {{ $results->getTo() }} of {{ $results->getTotal() }} entries</div>
	</div>
	<div class="col-xs-14 text-center">
		<div class="no-margin">
		{{ $results->appends(Input::all())->links() }}
		</div>
	</div>
</div>

<div id="items-container" class="well container" style="margin: 10px; ">
	<button type="button" class="btn btn-primary btn-lg prev-po_btn pull-right" data-toggle="modal" data-target="#prevPoModal">
	 {{ $btn_preview_po }}
	</button>
	<div class="clearfix"></div>

	<h3>{{ $text_purchase_order_products }}<span class='vendor-name'></span></h3>
	<div class="groups" style="margin: 7px 0; max-height: 300px; min-height: 100px; overflow-y: auto;"></div>
	
	<div class="clearfix"></div>
	<button type="button" class="btn btn-primary btn-lg prev-po_btn pull-right" data-toggle="modal" data-target="#prevPoModal">
	 {{ $btn_preview_po }}
	</button>
</div>
<div id="prevPoModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="prevPoLabel" aria-hidden="true">
	<div class="modal-dialog modal-lg">
		<div class="modal-content" style="min-height: 250px">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="{{ $btn_close }}"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="prevPoLabel">{{ $text_purchase_order_preview }}</h4>
			</div>
			<div class="modal-body">
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">{{ $btn_close }}</button>
				<button id="generatePo" type="button" class="btn btn-primary">{{ $btn_generate_po }}</button>
			</div>
		</div>
	 </div>
</div>

@else
	<p>{{ $text_no_result_found }}</p>
@endif
			
<script src="{{ Asset::bea('javascript/jquery/jquery.' . Backtrack::getRouteName() . '-list.js') }}"></script>